home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / RAMDisk sample / RamDisk.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-31  |  5.5 KB  |  227 lines  |  [TEXT/MPS ]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    StandardFileIcons: A sample control panel changing behavior of StandardFile.
  5. **
  6. **    by Gordon Sheridan and Jim Luther
  7. **  modified by Brian Bechtel
  8. **
  9. **    File:        RamDisk.h
  10. **
  11. **    Copyright © 1992-1994 Apple Computer, Inc.
  12. **    All rights reserved.
  13. **
  14. **    You may incorporate this sample code into your applications without
  15. **    restriction, though the sample code has been provided "AS IS" and the
  16. **    responsibility for its operation is 100% yours.  However, what you are
  17. **    not permitted to do is to redistribute the source as "DTS Sample Code"
  18. **    after having made changes. If you're going to re-distribute the source,
  19. **    we require that you make it clear in the source that the code was
  20. **    descended from Apple Sample Code, but that you've made changes.
  21. **
  22. ** Change History (most recent first):
  23. ** 
  24. **     <4>     8/12/94    BL°B    Changed Panic macros to use traps instead of actual hex values
  25. **      <3>    10/14/93    JML        Added Panic debug macros and changed preprocessor constants
  26. **                                 to enums.
  27. **      <2>     6/13/93    gs        Move dCtlFlag bits from RamDRVR.c and cleanup header.
  28. **      <1>     8/24/92    gs        first checked in
  29. **/
  30.  
  31. #ifndef __RAMDISK__
  32. #define __RAMDISK__
  33.  
  34. #ifndef rez
  35.  
  36. #include <Types.h>
  37. #include <Errors.h>
  38. #include <LowMem.h>
  39. #include <Traps.h>
  40. #include <GestaltEqu.h>
  41. #include <Memory.h>
  42. #include <Quickdraw.h>
  43. #include <DiskInit.h>
  44. #include <SegLoad.h>
  45. #include <OSUtils.h>
  46. #include <Script.h>
  47. #include <ToolUtils.h>
  48. #include <Events.h>
  49. #include <Controls.h>
  50. #include <TextEdit.h>
  51. #include <Desk.h>
  52. #include <Windows.h>
  53. #include <Dialogs.h>
  54. #include <Devices.h>
  55. #include <Disks.h>
  56. #include <Files.h>
  57. #include <Resources.h>
  58. #include <Packages.h>
  59.  
  60. #ifdef __MWERKS__
  61. #include <A4Stuff.h>
  62. #endif
  63. #ifdef THINK_C
  64. #include <SetupA4.h>
  65. #endif
  66.  
  67.  
  68. #if __DebugVersion
  69.     #define BreakPoint()    Debugger()
  70.     #define    Panic(message)    DebugStr(message)
  71.     #define PanicIf(condition, message)    do { if (condition) Panic(message); } while (0)
  72. #else
  73.     #define BreakPoint()
  74.     #define Panic(param)
  75.     #define PanicIf(param1,param2)
  76. #endif
  77.  
  78.  
  79. #define        kDriverName        "\p.RamDRVR"
  80. #define        kDRVRType        'DRVR'
  81.  
  82.  
  83. /*
  84. **    dCtlFlags bits
  85. */
  86.  
  87. #define        dNeedLock        0x4000
  88. #define        dNeedTime        0x2000
  89. #define        dNeedGoodBye    0x1000
  90. #define        dStatEnable        0x0800
  91. #define        dCtlEnable        0x0400
  92. #define        dWritEnable        0x0200
  93. #define        dReadEnable        0x0100
  94. #define        drvrActive        0x0080
  95. #define        dRAMBased        0x0040
  96. #define        dOpened            0x0020
  97.  
  98.  
  99. /*
  100. **    Low byte of trap word for _Read and _Write
  101. */
  102.  
  103. #define        aRdCmd            2
  104. #define        aWrCmd            3
  105.  
  106.  
  107. /*
  108. **    Standard disk driver csCodes
  109. */
  110.  
  111. /* Control codes */
  112. #define        killIOCC        1        /* kill I/O */
  113. #define        verifyDiskCC    5        /* verify disk */
  114. #define        formatDiskCC    6        /* format disk */
  115. #define        ejectDiskCC        7        /* eject disk (ejectable media only) */
  116. #define        setTagBufferCC    8        /* set tag buffer (.SONY) */
  117. #define        trackCacheCC    9,        /* control track cache (.SONY) */
  118. #define        physicalIconCC    21        /* return physical location icon and where string */
  119. #define        mediaIconCC        22        /* return media icon */
  120. #define        driveInfoCC        23        /* return drive info */
  121. #define        trackDumpCC        18244    /* diagnostic raw track dump (.SONY) */
  122.     
  123. /* Status codes */
  124. #define        returnFormatList 6        /* return format list (.SONY) */
  125. #define        driveStatusSC    8        /* drive status */
  126.  
  127.  
  128. /*
  129. **    Our driver specific csCodes
  130. */
  131.  
  132. /* Control codes */
  133. #define        setGlobalsCC    128        /* copy data pointed to by csParam to driver globals */
  134.     
  135. /* Status codes */
  136. #define        getGlobalsSC    128        /* return pointer to driver globals */
  137.  
  138.  
  139. /*
  140. **    Unit table constants
  141. */
  142.  
  143. #define        kMaxUTEntries    128        /* maximum size of unit table */
  144. #define        kMinUnitNum        48        /* the lowest unit number we can use */
  145.  
  146.  
  147. /* Driver globals structure */
  148. struct DrvrGlobals
  149. {
  150.     Ptr            ramDisk;
  151.     long        ramSize;
  152.     short        driveNumber;
  153.     Str255        volumeName;
  154.     long        physicalIcon[kLargeIconSize/4];    /* IMPORTANT: icon and whereString must be  */
  155.     Str255        locationStr;                /* end-to-end in memory! */
  156.     long        mediaIcon[kLargeIconSize/4];
  157. };
  158. typedef struct DrvrGlobals DrvrGlobals;
  159. typedef DrvrGlobals *DrvrGlobalsPtr, **DrvrGlobalsHandle;
  160.  
  161.  
  162. /* ConfigRec resource structure */
  163. struct ConfigRec
  164. {
  165.     short        install;    /* boolean true/false */
  166.     long        size;
  167.     Str255        volumeName;
  168. };
  169. typedef struct ConfigRec ConfigRec;
  170. typedef ConfigRec *ConfigRecPtr, **ConfigRecHandle;
  171.  
  172.  
  173. /* A DrvQEl with flags */
  174. struct MyDrvQEl
  175. {
  176.     long            flags;
  177.     QElemPtr        qLink;
  178.     short            qType;
  179.     short            dQDrive;
  180.     short            dQRefNum;
  181.     short            dQFSID;
  182.     unsigned short    dQDrvSz;
  183.     unsigned short    dQDrvSz2;
  184. };
  185. typedef struct MyDrvQEl MyDrvQEl;
  186. typedef MyDrvQEl *MyDrvQElPtr;
  187.  
  188.  
  189. /* FormatListRec as returned Return Format List status call (csCode = 6). */
  190. struct FormatListRec
  191. {
  192.     unsigned long                volSize;            /* disk capacity in SECTORs */
  193.     SignedByte                    formatFlags;        /* flags */
  194.     SignedByte                    sectorsPerTrack;    /* sectors per track side */
  195.     unsigned short                tracks;                /* number of tracks */
  196. };
  197. typedef struct FormatListRec FormatListRec;
  198. typedef FormatListRec *FormatListRecPtr;
  199.  
  200.  
  201. #endif    /* end of non-rez */
  202.  
  203.  
  204. /*
  205. **    Our resource IDs
  206. */
  207.  
  208. #define        rCDevSignature        0        /* RamDisk's registered signature ('RDsk') resource ID */
  209. #define        rCdev                -4064    /* Required cdev resource ID */
  210.  
  211. #define        rStringList            -4033
  212. #define        rLocationStr        1        /* The "where" string used in the Get Info dialog */
  213. #define        rDefaultNameStr        2        /* The initial default volume name */
  214.  
  215. /* icon family resource IDs */
  216. #define        rLoadOKIcon            -4064    /* same as cdev icon */
  217. #define        rLoadBadIcon        -4033
  218. #define        rPhysicalIcon        -4034
  219. #define        rMediaIcon            -4035
  220.  
  221. /* cdev dialog item resource IDs */
  222. #define        rCDevCheckbox        -4033
  223. #define        rCDevLogoPICT        -4033
  224. #define        rCDevSizeBarPICT    -4034
  225.  
  226. #endif __RAMDISK__
  227.